package com.bbcare.comm;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONObject;

//卵巢早衰压力问卷，结果计算
public class MateOSI {
	private final static Log logger = LogFactory.getLog(MateOSI.class);

	// 根据任务规则，计算开始结束时间
	public static double getTaskRuleTime(JSONObject pIn, String str) {
		logger.info("getTaskRuleTime" + pIn);
		String[] strs = { "设计", "摄影", "摄像" };// 视觉
		String[] str2 = { "显示器", "电脑", "单反", "摄像机", "鼠标" };// 视觉工具
		String[] str3 = { "保安", "警察", "空中交通管制员" };// 视觉
		String[] str4 = { "焊接", "驾驶", "演习" };// 视觉
		double score = 0;
		if ("IUT".equals(str)) {
			score = getIUT(pIn);
		} else if ("CUT".equals(str)) {
			score = getCUT(pIn);
		} else if ("OUT".equals(str)) {
			score = getOUT(pIn);
		} else if ("GUT".equals(str)) {
			score = getGUT(pIn);
		} else if ("IHT".equals(str)) {
			score = getIHT(pIn, strs, str2);
		} else if ("CHT".equals(str)) {
			score = getCHT(pIn);
		} else if ("OHT".equals(str)) {
			score = getOHT(pIn);
		} else if ("GHT".equals(str)) {
			score = getGHT(pIn);
		} else if ("IST".equals(str)) {
			score = getIST(pIn);
		} else if ("CST".equals(str)) {
			score = getCST(pIn);
		} else if ("OST".equals(str)) {
			score = getOST(pIn);
		} else if ("GST".equals(str)) {
			score = getGST(pIn);
		} else if ("IEPT".equals(str)) {
			score = getIEPT(pIn);
		} else if ("CEPT".equals(str)) {
			score = getCEPT(pIn);
		} else if ("OEPT".equals(str)) {
			score = getOEPT(pIn);
		} else if ("GEPT".equals(str)) {
			score = getGEPT(pIn);
		} else if ("INOXT".equals(str)) {
			score = getINOXT(pIn);
		} else if ("ONOXT".equals(str)) {
			score = getONOXT(pIn);
		} else if ("GNOXT".equals(str)) {
			score = getGNOXT(pIn);
		} else if ("IAVOIT".equals(str)) {
			score = getIAVOIT(pIn, str3);
		} else if ("CAVOIT".equals(str)) {
			score = getCAVOIT(pIn);
		} else if ("OAVOIT".equals(str)) {
			score = getOAVOIT(pIn, str4);
		} else if ("GAVOIT".equals(str)) {
			score = getGAVOIT(pIn);
		} else if ("ICNFLT".equals(str)) {
			score = getICNFLT(pIn);
		} else if ("CCNFLT".equals(str)) {
			score = getCCNFLT(pIn);
		} else if ("OCNFLT".equals(str)) {
			score = getOCNFLT(pIn);
		} else if ("GCNFLT".equals(str)) {
			score = getGCNFLT(pIn);
		}
		return score;
	}

	// 计算IUT
	private static int getIUT(JSONObject pIn) {
		int IU1 = 0;
		int IU2 = 0;
		int IU3 = 0;
		if ("a".equals(pIn.get("H3")) || "b".equals(pIn.get("H3"))) {
			IU1 = 0;
		} else if ("d".equals(pIn.get("H3"))) {
			if (!StringUtils.isBlank((String) pIn.get("H1"))) {
				int n = pIn.get("H1").toString().length() - pIn.get("H1").toString().replaceAll(";", "").length() + 1;
				if (n < 3) {
					IU1 = 2;
				}
			}
		} else {
			IU1 = 1;
		}

		if ("a".equals(pIn.get("F3")) || "b".equals(pIn.get("F3"))) {
			IU2 = 0;
		} else {
			IU2 = 2;
		}

		if ("a".equals(pIn.get("J1"))) {
			IU3 = 2;
		} else {
			IU3 = 0;
		}

		int IUT = IU1 + IU2 + IU3;
		return IUT;
	}

	// 计算CUT
	private static int getCUT(JSONObject pIn) {
		int CUT = 0;
		if ((!"a".equals(pIn.get("I2")) && !"b".equals(pIn.get("I2"))) || !"a".equals(pIn.get("I1-1"))) {
			CUT = 0;
		} else if ("b".equals(pIn.get("I2")) && "a".equals(pIn.get("I1-1"))) {
			CUT = 1;
		} else if ("a".equals(pIn.get("I2")) && "a".equals(pIn.get("I1-1"))) {
			CUT = 2;
		}
		return CUT;
	}

	// 计算OUT
	private static double getOUT(JSONObject pIn) {
		double OU1 = 0;
		double OU2 = 0;
		double OU3 = 0;
		int n = 0;
		int n2 = 0;
		if (!StringUtils.isBlank((String) pIn.get("H1"))) {
			n = pIn.get("H1").toString().length() - pIn.get("H1").toString().replaceAll(";", "").length() + 1;
		}
		if (!StringUtils.isBlank((String) pIn.get("H2"))) {
			n2 = pIn.get("H2").toString().length() - pIn.get("H2").toString().replaceAll(";", "").length() + 1;
		}
		if (("a".equals(pIn.get("H3")) || "b".equals(pIn.get("H3")))) {
			OU1 = 0;
		} else if ("c".equals(pIn.get("H3"))) {
			OU1 = 1;
		} else if ("d".equals(pIn.get("H3")) && n >= 3) {
			OU1 = 1.5;
		} else if ("d".equals(pIn.get("H3")) && n <= 2) {
			OU1 = 2;
		}

		if (n <= 4 && n2 <= 4) {
			OU2 = 0;
		} else if (n > 4 || n > 4) {
			OU2 = 2;
		}

		if ("a".equals(pIn.get("H4"))) {
			OU3 = 0;
		} else if ("b".equals(pIn.get("H4"))) {
			OU3 = 1;
		} else if ("c".equals(pIn.get("H4"))) {
			OU3 = 1.5;
		} else if ("d".equals(pIn.get("H4"))) {
			OU3 = 2;
		}
		double OUT = OU1 + OU2 + OU3;
		return OUT;
	}

	// 计算GUT
	private static double getGUT(JSONObject pIn) {
		double GU1 = 0;
		double GU2 = 0;
		double GU3 = 0;
		double GU4 = 0;
		if ("c".equals(pIn.get("C1"))) {
			GU1 = 2;
		} else {
			GU1 = 0;
		}
		if ("a".equals(pIn.get("C2"))) {
			GU2 = 0;
		} else if ("b".equals(pIn.get("C2"))) {
			GU2 = 0.5;
		} else if ("c".equals(pIn.get("C2"))) {
			GU2 = 1;
		} else if ("d".equals(pIn.get("C2"))) {
			GU2 = 2;
		}

		if ("b".equals(pIn.get("C3-1"))) {
			GU3 = 2;
		} else if ("a".equals(pIn.get("C3-1")) && "d".equals(pIn.get("C3-2"))) {
			GU3 = 1;
		} else {
			GU3 = 0;
		}

		if ("a".equals(pIn.get("C5"))) {
			GU4 = 0;
		} else if ("b".equals(pIn.get("C5"))) {
			GU4 = 0.5;
		} else if ("c".equals(pIn.get("C5"))) {
			GU4 = 1.5;
		} else if ("d".equals(pIn.get("C5"))) {
			GU4 = 2;
		}

		double GUT = GU1 + GU2 + GU3 + GU4;
		return GUT;
	}

	// 计算IHT
	private static double getIHT(JSONObject pIn, String[] str1, String[] str2) {
		double IH1 = 0;
		double IH2 = 0;
		double IH3 = 0;
		double IH4 = 0;
		double IH5 = 0;
		double IH6 = 0;
		if (("a".equals(pIn.get("H5")) || "b".equals(pIn.get("H5")))
				&& ("a".equals(pIn.get("I1-1")) || "b".equals(pIn.get("I1-1")))) {
			IH1 = 0;
		} else {
			IH1 = 2;
		}
		int n = 0;
		if (!StringUtils.isBlank((String) pIn.get("H1"))) {
			n = pIn.get("H1").toString().length() - pIn.get("H1").toString().replaceAll(";", "").length() + 1;
		}
		if ("c".equals(pIn.get("H3")) || "d".equals(pIn.get("H3"))) {
			IH2 = 0;
		} else if (n <= 5) {
			IH2 = 1;
		} else {
			IH2 = 2;
		}

		String[] str = null;
		if (!StringUtils.isBlank((String) pIn.get("H1"))) {
			str = pIn.get("H1").toString().split(";");
		}
		boolean have = false;// H1如果一条满足就成立
		boolean have1 = true;// H1用户判断是否所有数据都包含了视觉作业
		boolean have5 = false;// H1用户判断是否所有数据都包含了视觉作业
		if (str != null) {
			for (int i = 0; i < str.length; i++) {
				for (int j = 0; j < str1.length; j++) {
					if (str[i].indexOf(str1[j]) > 0) {
						have = true;
						break;
					} else {
						// 如果到最后一个还没有匹配上那么说明此条数据未包含数组中的信息
						if (j == str.length - 1) {
							have1 = false;
							have5 = true;
						}
					}
				}
			}
		}
		if (have5 == false) {
			have1 = false;
		}
		String[] str3 = null;
		if (!StringUtils.isBlank((String) pIn.get("H2"))) {
			str3 = pIn.get("H2").toString().split(";");
		}
		boolean have2 = false;// H2如果一条满足就成立
		boolean have3 = true;// H2用户判断是否所有数据都包含了视觉作业
		boolean have6 = false;// H1用户判断是否所有数据都包含了视觉作业
		if (str3 != null) {
			for (int i = 0; i < str3.length; i++) {
				for (int j = 0; j < str2.length; j++) {
					if (str3[i].indexOf(str2[j]) > 0) {
						have2 = true;
						break;
					} else {
						// 如果到最后一个还没有匹配上那么说明此条数据未包含数组中的信息
						if (j == str2.length - 1) {
							have3 = false;
						}
					}
				}
			}
		}
		if (have6 == false) {
			have3 = false;
		}
		if (have == true && have1 == true && have2 == true && have3 == true) {
			IH3 = 2;
		} else if (have == false && have1 == false && have2 == false && have3 == false) {
			IH3 = 0;
		} else {
			IH3 = 1;
		}

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("", "");

		if ((("a".equals(pIn.get("F3")) || "b".equals(pIn.get("F3")))
				&& ("a".equals(pIn.get("J3-1")) && "a".equals(pIn.get("J3-3")))) || "a".equals(pIn.get("J8"))) {
			IH4 = 0;
		} else {
			IH4 = 2;
		}

		if ("a".equals(pIn.get("H5")) || "b".equals(pIn.get("H5"))) {
			IH5 = 0;
		} else {
			IH5 = 2;
		}

		if ("a".equals(pIn.get("J1"))) {
			IH6 = 0;
		} else if ("b".equals(pIn.get("J1"))) {
			IH6 = 1;
		} else if ("c".equals(pIn.get("J1"))) {
			IH6 = 2;
		}

		double GUT = IH1 + IH2 + IH3 + IH4 + IH5 + IH6;
		return GUT;
	}

	// 计算CHT
	private static double getCHT(JSONObject pIn) {
		double CH1 = 0;
		double CH2 = 0;
		double CH3 = 0;
		double CH4 = 0;
		int manage = 0;
		if (!StringUtils.isBlank((String) pIn.get("I1-2"))) {
			manage = Integer.parseInt(pIn.get("I1-2").toString());
		}
		if (("a".equals(pIn.get("I2")) || "b".equals(pIn.get("I2")) || "c".equals(pIn.get("I2")))
				&& ("a".equals(pIn.get("I1-1")) || "b".equals(pIn.get("I1-1")))) {
			CH1 = 0;
		} else if (("d".equals(pIn.get("I2")) || "e".equals(pIn.get("I2"))
				|| (("c".equals(pIn.get("I1-1")) || "d".equals(pIn.get("I1-1"))) && manage >= 1 && manage <= 3))
				&& ("a".equals(pIn.get("I3")) || "b".equals(pIn.get("I3")))) {
			CH1 = 1;
		} else if (("d".equals(pIn.get("I2")) || "e".equals(pIn.get("I2"))
				|| (("c".equals(pIn.get("I1-1")) || "d".equals(pIn.get("I1-1"))) && manage > 3))
				&& ("c".equals(pIn.get("I3")) || "d".equals(pIn.get("I3")))) {
			CH1 = 2;
		}

		if (("a".equals(pIn.get("I2")) || "b".equals(pIn.get("I2")) || "c".equals(pIn.get("I2")))
				&& ("a".equals(pIn.get("I1-1")) || "b".equals(pIn.get("I1-1")))) {
			CH2 = 0;
		} else if (("d".equals(pIn.get("I2")) || "e".equals(pIn.get("I2"))
				|| (("c".equals(pIn.get("I1-1")) || "d".equals(pIn.get("I1-1"))) && manage >= 1 && manage <= 3))
				&& ("a".equals(pIn.get("I3")) || "b".equals(pIn.get("I3")))) {
			CH2 = 1;
		} else if (("d".equals(pIn.get("I2")) || "e".equals(pIn.get("I2"))
				|| (("c".equals(pIn.get("I1-1")) || "d".equals(pIn.get("I1-1"))) && manage > 3))
				&& ("c".equals(pIn.get("I3")) || "d".equals(pIn.get("I3")))) {
			CH2 = 2;
		}

		if ("a".equals(pIn.get("I1-1"))) {
			CH3 = 0;
		} else if ("b".equals(pIn.get("I1-1"))) {
			CH3 = 0.5;
		} else if ("c".equals(pIn.get("I1-1"))) {
			CH3 = 1;
		} else if ("d".equals(pIn.get("I1-1"))) {
			CH3 = 2;
		}

		if ("a".equals(pIn.get("I4-1"))) {
			CH4 = 0;
		} else if ("b".equals(pIn.get("I4-1"))) {
			CH4 = 0.5;
		} else if ("c".equals(pIn.get("I4-1"))) {
			CH4 = 1;
		} else if ("d".equals(pIn.get("I4-1"))) {
			CH4 = 2;
		}

		double CHT = CH1 + CH2 + CH3 + CH4;
		return CHT;
	}

	// OHT
	private static double getOHT(JSONObject pIn) {
		double OH1 = 0;
		double OH2 = 0;
		double OH3 = 0;
		double OH4 = 0;
		if ("c".equals(pIn.get("H3")) || "d".equals(pIn.get("H3"))) {
			OH1 = 0;
		} else {
			int n = 0;
			if (!StringUtils.isBlank((String) pIn.get("H1"))) {
				n = pIn.get("H1").toString().length() - pIn.get("H1").toString().replaceAll(";", "").length() + 1;
			}
			if (n >= 1 && n <= 2) {
				OH1 = 1;
			}
			if ("b".equals(pIn.get("H3")) && n > 3) {
				OH1 = 1.5;
			} else if ("a".equals(pIn.get("H3")) && n > 3) {
				OH1 = 2;
			}
		}

		if ("a".equals(pIn.get("H5"))) {
			OH2 = 0;
		} else if ("b".equals(pIn.get("H5"))) {
			OH2 = 0.5;
		} else if ("c".equals(pIn.get("H5"))) {
			OH2 = 1;
		} else if ("d".equals(pIn.get("H5"))) {
			OH2 = 2;
		}
		int n = 0;
		if (!StringUtils.isBlank((String) pIn.get("H1"))) {
			n = pIn.get("H1").toString().length() - pIn.get("H1").toString().replaceAll(";", "").length() + 1;
		}
		if (n >= 1 && n <= 2) {
			OH3 = 0;
		} else if (n >= 3 && n <= 4) {
			OH3 = 1;
		} else {
			OH3 = 2;
		}

		if ("a".equals(pIn.get("H6-1"))) {
			OH4 = 0;
		} else if ("b".equals(pIn.get("H6-1"))) {
			OH4 = 0.5;
		} else if ("c".equals(pIn.get("H6-1"))) {
			OH4 = 1;
		} else if ("d".equals(pIn.get("H6-1"))) {
			OH4 = 2;
		}
		double OHT = OH1 + OH2 + OH3 + OH4;
		return OHT;
	}

	// GHT
	private static double getGHT(JSONObject pIn) {
		double CH1 = 0;
		double CH2 = 0;
		double CH3 = 0;
		double CH4 = 0;
		double CH5 = 0;
		double CH6 = 0;
		if ("a".equals(pIn.get("C1"))) {
			CH1 = 2;
		} else if ("b".equals(pIn.get("C1"))) {
			CH1 = 1;
		} else {
			CH1 = 0;
		}
		double score = 0;
		if (!StringUtils.isBlank((String) pIn.get("B1-1")) && !StringUtils.isBlank((String) pIn.get("B2"))) {
			score = Double.parseDouble(pIn.get("B1-1").toString()) * Double.parseDouble(pIn.get("B2").toString());
		}
		if (score <= 40) {
			CH2 = 0;
		} else if (score > 40 && score <= 42) {
			CH2 = 0.5;
		} else if (score > 42 && score <= 48) {
			CH2 = 1;
		} else {
			CH2 = 2;
		}
		if (CH2 < 2) {
			if ("c".equals(pIn.get("B4")) || "d".equals(pIn.get("B4"))) {
				CH2 = CH2 + 0.5;
			}
		}
		if ("c".equals(pIn.get("B14")) || "d".equals(pIn.get("B14"))) {
			if (CH2 < 2) {
				CH2 = CH2 + 0.5;
			}
		}

		if ("a".equals(pIn.get("B6-1"))) {
			CH3 = 2;
		} else {
			CH3 = 0;
		}

		if ("a".equals(pIn.get("B7"))) {
			CH4 = 2;
		} else if ("b".equals(pIn.get("B7"))) {
			CH4 = 1.5;
		} else if ("c".equals(pIn.get("B7"))) {
			CH4 = 1;
		} else if ("d".equals(pIn.get("B7"))) {
			CH4 = 0;
		}
		if (CH4 < 2) {
			if ("a".equals(pIn.get("B8")) && "b".equals(pIn.get("B9-1"))) {
				CH4 = CH4 + 0.5;
			}
		}
		double b10 = 0;
		if (!StringUtils.isBlank((String) pIn.get("B10"))) {
			b10 = Double.parseDouble(pIn.get("B10").toString());
		}
		if (b10 > 2) {
			if (CH4 < 2) {
				CH4 = CH4 + 0.5;
			}
		}
		if ("a".equals(pIn.get("B3-1")) && "b".equals(pIn.get("B11-1"))) {
			CH5 = 0;
		} else if ("b".equals(pIn.get("B3-1")) && "b".equals(pIn.get("B11-1"))) {
			CH5 = 0.5;
		} else if ("a".equals(pIn.get("B11-1")) && "a".equals(pIn.get("B11-2"))) {
			CH5 = 1;
		} else if ("a".equals(pIn.get("B11-1")) && "b".equals(pIn.get("B11-2"))) {
			double day = 0;
			if (!StringUtils.isBlank((String) pIn.get("B11-2-a"))) {
				day = Double.parseDouble(pIn.get("B11-2-a").toString());
			}
			if (day <= 4) {
				CH5 = 1.5;
			} else {
				double average = 30 / day;
				if (average >= 7 && average <= 4) {
					CH5 = 1.75;
				} else {
					CH5 = 2;
				}
			}
		}

		if (CH5 < 2) {
			double day = 0;
			if (!StringUtils.isBlank((String) pIn.get("B11-2-b"))) {
				day = Double.parseDouble(pIn.get("B11-2-b").toString()) * 24;
			}
			if (day < 24) {
				CH5 = CH5 + 0.5;
			}
		}

		if ("b".equals(pIn.get("B3-1"))) {
			if (CH5 < 2) {
				CH5 = CH5 + 0.5;
			}
		}

		if (CH5 > 2) {
			CH5 = 2;
		}
		double week = 0;
		if (!StringUtils.isBlank((String) pIn.get("B5-1"))) {
			week = Double.parseDouble(pIn.get("B5-1").toString());
		}
		if (week > 4) {
			CH6 = 0;
		} else if (week >= 3 && week <= 4) {
			CH6 = 1;
		} else if (week == 2) {
			CH6 = 1.5;
		} else {
			CH6 = 2;
		}
		double CHT = CH6 + CH5 + CH4 + CH3 + CH2 + CH1;
		return CHT;
	}

	// 计算IST
	private static double getIST(JSONObject pIn) {

		double IST = 0;
		if ("a".equals(pIn.get("G7"))) {
			IST = 0;
		} else if ("b".equals(pIn.get("G7"))) {
			IST = 0.5;
		} else if ("c".equals(pIn.get("G7"))) {
			IST = 1;
		} else if ("d".equals(pIn.get("G7"))) {
			IST = 2;
		}
		return IST;
	}

	// 计算CST
	private static double getCST(JSONObject pIn) {

		double CS1 = 0;
		double CS2 = 0;
		if ("a".equals(pIn.get("I6"))) {
			CS1 = 0;
		} else if ("b".equals(pIn.get("I6"))) {
			CS1 = 0.5;
		} else if ("c".equals(pIn.get("I6"))) {
			CS1 = 1;
		} else if ("d".equals(pIn.get("I6"))) {
			CS1 = 2;
		}
		if ("a".equals(pIn.get("I5"))) {
			CS2 = 0;
		}
		if ("b".equals(pIn.get("I5"))) {
			CS2 = 0.5;
		} else if ("c".equals(pIn.get("I5"))) {
			CS2 = 1;
		} else if ("d".equals(pIn.get("I5"))) {
			CS2 = 2;
		}
		double CST = CS1 + CS2;
		return CST;
	}

	// 计算OST
	private static double getOST(JSONObject pIn) {

		double OST = 0;
		if ("a".equals(pIn.get("C4"))) {
			OST = 0;
		} else if ("b".equals(pIn.get("C4"))) {
			OST = 1;
		} else {
			OST = 2;
		}
		return OST;
	}

	// 计算GST
	private static double getGST(JSONObject pIn) {
		double GS1 = 0;
		double GS2 = 0;
		double GS3 = 0;
		double GS4 = 0;
		double GS5 = 0;
		double GS6 = 0;
		double GS7 = 0;
		double GS8 = 0;
		if ("a".equals(pIn.get("D8-1"))) {
			GS1 = 0;
		} else if ("b".equals(pIn.get("D8-1"))) {
			GS1 = 1;
		} else {
			GS1 = 2;
		}

		if ("a".equals(pIn.get("D10")) || "b".equals(pIn.get("D10"))) {
			GS2 = 0;
		} else if ("a".equals(pIn.get("D11")) && (("b".equals(pIn.get("D12"))
				&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13"))))
				|| ("a".equals(pIn.get("D12"))
						&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13")) || "c".equals(pIn.get("D13")))))) {
			GS2 = 0.5;
		} else if ("b".equals(pIn.get("D11")) && (("b".equals(pIn.get("D12"))
				&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13"))))
				|| ("a".equals(pIn.get("D12"))
						&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13")) || "c".equals(pIn.get("D13")))))) {
			GS2 = 1;
		} else if ("c".equals(pIn.get("D11")) && (("b".equals(pIn.get("D12"))
				&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13"))))
				|| ("a".equals(pIn.get("D12"))
						&& ("b".equals(pIn.get("D13")) || "b".equals(pIn.get("D13")) || "c".equals(pIn.get("D13")))))) {
			GS2 = 1.5;
		} else if ("b".equals(pIn.get("D11")) && ("c".equals(pIn.get("D12"))
				|| ("b".equals(pIn.get("D12"))
						&& ("c".equals(pIn.get("D13")) || "d".equals(pIn.get("D13")) || "e".equals(pIn.get("D13"))))
				|| ("a".equals(pIn.get("D12")) && ("d".equals(pIn.get("D13")) || "e".equals(pIn.get("D13")))))) {
			GS2 = 1.75;
		} else if ("c".equals(pIn.get("D11")) && ("c".equals(pIn.get("D12"))
				|| ("b".equals(pIn.get("D12"))
						&& ("c".equals(pIn.get("D13")) || "d".equals(pIn.get("D13")) || "e".equals(pIn.get("D13"))))
				|| ("a".equals(pIn.get("D12")) && ("d".equals(pIn.get("D13")) || "e".equals(pIn.get("D13")))))) {
			GS2 = 2;
		}

		if ("b".equals(pIn.get("D14"))) {
			if (GS2 < 2) {
				GS2 = GS2 + 0.5;
			}
			if (GS2 > 2) {
				GS2 = 2;
			}
		}

		if ("b".equals(pIn.get("D9"))) {
			GS3 = 2;
		} else if ("b".equals(pIn.get("D13")) || "c".equals(pIn.get("D13")) || "d".equals(pIn.get("D13"))
				|| "e".equals(pIn.get("D13"))) {
			GS3 = 1;
		} else {
			GS3 = 0;
		}

		if ("a".equals(pIn.get("B12"))) {
			GS4 = 0;
		} else if ("b".equals(pIn.get("B12"))) {
			GS4 = 1;
		} else if ("c".equals(pIn.get("B12"))) {
			GS4 = 1.5;
		} else if ("d".equals(pIn.get("B12"))) {
			GS4 = 2;
		}

		if ("a".equals(pIn.get("B13"))) {
			GS5 = 0;
		} else if ("b".equals(pIn.get("B13"))) {
			GS5 = 0.5;
		} else if ("c".equals(pIn.get("B13"))) {
			GS5 = 1.5;
		} else if ("d".equals(pIn.get("B13"))) {
			GS5 = 2;
		}

		if ("a".equals(pIn.get("I7"))) {
			GS6 = 0;
		} else if ("b".equals(pIn.get("I7"))) {
			GS6 = 0.5;
		} else if ("c".equals(pIn.get("I7"))) {
			GS6 = 1.5;
		} else if ("d".equals(pIn.get("I7"))) {
			GS6 = 2;
		}

		if ("a".equals(pIn.get("I8"))) {
			GS7 = 0;
		} else if ("b".equals(pIn.get("I8"))) {
			GS7 = 0.5;
		} else if ("c".equals(pIn.get("I8"))) {
			GS7 = 1.5;
		} else if ("d".equals(pIn.get("I8"))) {
			GS7 = 2;
		}

		if ("a".equals(pIn.get("I9"))) {
			GS8 = 0;
		} else if ("b".equals(pIn.get("I9"))) {
			GS8 = 0.5;
		} else if ("c".equals(pIn.get("I9"))) {
			GS8 = 1.5;
		} else if ("d".equals(pIn.get("I9"))) {
			GS8 = 2;
		}

		double GST = GS1 + GS2 + GS3 + GS4 + GS5 + GS6 + GS7 + GS8;
		return GST;
	}

	// 计算IEPT
	private static double getIEPT(JSONObject pIn) {
		double IEPT = 0;
		if ("a".equals(pIn.get("F3"))) {
			IEPT = 0;
		} else if ("b".equals(pIn.get("F3"))) {
			IEPT = 0.5;
		} else if ("c".equals(pIn.get("F3"))) {
			IEPT = 1;
		} else if ("d".equals(pIn.get("F3"))) {
			IEPT = 2;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("J4", pIn.get("J4"));
		map.put("J5", pIn.get("J5"));
		map.put("J6", pIn.get("J6"));
		map.put("J7", pIn.get("J7"));
		map.put("J8", pIn.get("J8"));
		map.put("J9", pIn.get("J9"));
		boolean include = false;
		for (String key : map.keySet()) {
			if ("c".equals(map.get(key)) || "d".equals(map.get(key)) || "e".equals(map.get(key))) {
				include = true;
				break;
			}
		}
		if (include == true && IEPT < 2) {
			IEPT = IEPT + 0.5;
		}
		if (IEPT < 2) {
			if ("b".equals(pIn.get("J3-3"))) {
				IEPT = IEPT + 0.5;
			}
		}
		return IEPT;
	}

	// 计算CEPT
	private static double getCEPT(JSONObject pIn) {
		double CEPT = 0;
		if ("a".equals(pIn.get("G1"))) {
			CEPT = 0;
		} else if ("b".equals(pIn.get("G1"))) {
			CEPT = 0.5;
		} else if ("c".equals(pIn.get("G1"))) {
			CEPT = 1;
		} else if ("d".equals(pIn.get("G1"))) {
			CEPT = 2;
		}
		return CEPT;
	}

	// 计算OEPT
	private static double getOEPT(JSONObject pIn) {
		double OEPT = 0;
		if ("a".equals(pIn.get("F3"))) {
			OEPT = 0;
		} else if ("b".equals(pIn.get("F3"))) {
			OEPT = 0.5;
		} else if ("c".equals(pIn.get("F3"))) {
			OEPT = 1;
		} else if ("d".equals(pIn.get("F3"))) {
			OEPT = 2;
		}
		return OEPT;
	}

	// 计算GEPT
	private static double getGEPT(JSONObject pIn) {
		double GEP1 = 0;
		double GEP2 = 0;
		if ("a".equals(pIn.get("F1"))) {
			GEP1 = 0;
		} else if ("b".equals(pIn.get("F1"))) {
			GEP1 = 0.5;
		} else if ("c".equals(pIn.get("F1"))) {
			GEP1 = 1;
		} else if ("d".equals(pIn.get("F1"))) {
			GEP1 = 2;
		}

		if ("a".equals(pIn.get("F2"))) {
			GEP2 = 0;
		} else if ("b".equals(pIn.get("F2"))) {
			GEP2 = 1;
		} else if ("c".equals(pIn.get("F2"))) {
			GEP2 = 1.5;
		} else if ("d".equals(pIn.get("F2"))) {
			GEP2 = 2;
		}

		double GEPT = GEP1 + GEP2;
		return GEPT;
	}

	// 计算INOXT
	private static double getINOXT(JSONObject pIn) {
		double INOX1 = 0;
		double INOX2 = 0;
		if ("a".equals(pIn.get("D1"))) {
			INOX1 = 0;
		} else if ("b".equals(pIn.get("D1"))) {
			INOX1 = 0.5;
		} else if ("c".equals(pIn.get("D1"))) {
			INOX1 = 1;
		} else if ("d".equals(pIn.get("D1"))) {
			INOX1 = 2;
		}

		if ("a".equals(pIn.get("D2"))) {
			INOX2 = 0;
		} else if ("b".equals(pIn.get("D2"))) {
			INOX2 = 1;
		} else if ("c".equals(pIn.get("D2"))) {
			INOX2 = 1.5;
		} else if ("d".equals(pIn.get("D2"))) {
			INOX2 = 2;
		}

		double INOXT = INOX1 + INOX2;
		return INOXT;
	}

	// 计算ONOXT
	private static double getONOXT(JSONObject pIn) {
		double ONOX1 = 0;
		double ONOX2 = 0;
		if ("a".equals(pIn.get("D3-1"))) {
			ONOX1 = 0;
		} else if ("b".equals(pIn.get("D3-1"))) {
			ONOX1 = 0.5;
		} else if ("c".equals(pIn.get("D3-1"))) {
			ONOX1 = 1;
		} else if ("d".equals(pIn.get("D3-1"))) {
			ONOX1 = 2;
		}

		if (!StringUtils.isBlank((String) pIn.get("D3-2"))) {
			if (Double.parseDouble(pIn.get("D3-2").toString()) > 30) {
				if (ONOX1 < 2) {
					ONOX1 = ONOX1 + 0.5;
				}
			}
		}

		if ("a".equals(pIn.get("D4-1"))) {
			ONOX2 = 0;
		} else if ("b".equals(pIn.get("D4-1"))) {
			ONOX2 = 0.5;
		} else if ("c".equals(pIn.get("D4-1"))) {
			ONOX2 = 1;
		} else if ("d".equals(pIn.get("D4-1"))) {
			ONOX2 = 2;
		}

		double ONOXT = ONOX1 + ONOX2;
		return ONOXT;
	}

	// 计算GNOXT
	private static double getGNOXT(JSONObject pIn) {
		double GNOX1 = 0;
		double GNOX2 = 0;
		double GNOX3 = 0;
		if ("a".equals(pIn.get("D5"))) {
			GNOX1 = 0;
		} else if ("b".equals(pIn.get("D5"))) {
			GNOX1 = 0.5;
		} else if ("c".equals(pIn.get("D5"))) {
			GNOX1 = 1;
		} else if ("d".equals(pIn.get("D5"))) {
			GNOX1 = 2;
		}
		if (GNOX1 < 2) {
			if ("b".equals(pIn.get("D14"))) {
				GNOX1 = GNOX1 + 0.5;
			}
		}

		if ("a".equals(pIn.get("D6"))) {
			GNOX2 = 0;
		} else if ("b".equals(pIn.get("D6"))) {
			GNOX2 = 0.5;
		} else if ("c".equals(pIn.get("D6"))) {
			GNOX2 = 1;
		} else if ("d".equals(pIn.get("D6"))) {
			GNOX2 = 2;
		}

		if (GNOX2 < 2) {
			if ("a".equals(pIn.get("D15"))) {
				GNOX2 = GNOX2 + 0.5;
			}
		}

		if ("a".equals(pIn.get("D7-1"))) {
			GNOX2 = 0;
		} else if ("b".equals(pIn.get("D7-1"))) {
			GNOX2 = 0.5;
		} else if ("c".equals(pIn.get("D7-1"))) {
			GNOX2 = 1;
		} else if ("d".equals(pIn.get("D7-1"))) {
			GNOX2 = 2;
		}

		double GNOXT = GNOX1 + GNOX2 + GNOX3;
		return GNOXT;
	}

	// 计算IAVOIT
	private static double getIAVOIT(JSONObject pIn, String[] str) {
		double IAVOI1 = 0;
		double IAVOI2 = 0;
		double IAVOI3 = 0;
		String A1 = (String) pIn.get("A1");
		if (A1 == null) {
			A1 = "";
		}
		boolean have = false;// H1如果一条满足就成立
		for (int j = 0; j < str.length; j++) {
			if (A1.indexOf(str[j]) > 0) {
				have = true;
				break;
			}
		}

		if (have == true) {
			IAVOI2 = 2;
		} else {
			if ("e".equals(pIn.get("D16"))) {
				IAVOI2 = 0;
			} else {
				IAVOI2 = 1;
			}
		}

		if ("a".equals(pIn.get("D17-1"))) {
			IAVOI2 = 0;
		} else if ("b".equals(pIn.get("D17-1"))) {
			IAVOI2 = 0.5;
		} else if ("c".equals(pIn.get("D17-1"))) {
			IAVOI2 = 1;
		} else if ("d".equals(pIn.get("D17-1"))) {
			IAVOI2 = 2;
		}

		if ("a".equals(pIn.get("G3-1"))) {
			IAVOI3 = 0;
		} else if ("b".equals(pIn.get("G3-1"))) {
			IAVOI3 = 0.5;
		} else if ("c".equals(pIn.get("G3-1"))) {
			IAVOI3 = 1;
		} else if ("d".equals(pIn.get("G3-1"))) {
			IAVOI3 = 2;
		}

		double IAVOIT = IAVOI1 + IAVOI2 + IAVOI3;
		return IAVOIT;
	}

	// 计算CAVOIT
	private static double getCAVOIT(JSONObject pIn) {
		double CAVOIT = 0;
		if ("a".equals(pIn.get("G4"))) {
			CAVOIT = 0;
		} else if ("b".equals(pIn.get("G4"))) {
			CAVOIT = 0.5;
		} else if ("c".equals(pIn.get("G4"))) {
			CAVOIT = 1;
		} else if ("d".equals(pIn.get("G4"))) {
			CAVOIT = 2;
		}
		return CAVOIT;
	}

	// 计算OAVOIT
	private static double getOAVOIT(JSONObject pIn, String[] str) {
		double OAVOIT = 0;
		String A1 = (String) pIn.get("A1");
		if (A1 == null) {
			A1 = "";
		}
		boolean have = false;// H1如果一条满足就成立
		for (int j = 0; j < str.length; j++) {
			if (A1.indexOf(str[j]) > 0) {
				have = true;
				break;
			}
		}
		if (have == false) {
			String[] str5 = null;
			String[] str6 = null;
			if (!StringUtils.isBlank((String) pIn.get("H1")) && !StringUtils.isBlank((String) pIn.get("H2"))) {
				str5 = pIn.get("H1").toString().split(";");
				str6 = pIn.get("H2").toString().split(";");
			}
			System.out.println("str5"+str5+ "= str6" +str6);
			String[] str7 = null;
			if(str5!=null&&str6==null) {
				str7 = str5;
			}else if(str5==null&&str6!=null) {
				str7 = str6;
			}else if(str5!=null&&str6!=null){
				str7 = concat(str5, str6);
			}
			if (str7 != null) {
				outer: for (int i = 0; i < str.length; i++) {
					for (int j = 0; j < str7.length; j++) {
						if (str[i].indexOf(str7[j]) > 0) {
							have = true;
							break outer;
						}
					}
				}
			}
		}

		if (have == true && "e".equals(pIn.get("D16"))) {
			OAVOIT = 1;
		} else if (have == false && "e".equals(pIn.get("D16"))) {
			OAVOIT = 0;
		} else {
			OAVOIT = 2;
		}

		return OAVOIT;
	}

	// 计算GAVOIT
	private static double getGAVOIT(JSONObject pIn) {
		double GAVOI1 = 0;
		double GAVOI2 = 0;
		double GAVOI3 = 0;
		double GAVOI4 = 0;
		double GAVOI5 = 0;
		if ("b".equals(pIn.get("E1-1"))) {
			GAVOI1 = 0;
		} else if ("a".equals(pIn.get("E1-1")) && "b".equals(pIn.get("E1-2"))) {
			GAVOI1 = 1;
		} else {
			GAVOI1 = 2;
		}

		if ("a".equals(pIn.get("E2"))) {
			GAVOI2 = 0;
		} else if ("b".equals(pIn.get("E2"))) {
			GAVOI2 = 0.5;
		} else if ("c".equals(pIn.get("E2"))) {
			GAVOI2 = 1;
		} else if ("d".equals(pIn.get("E2"))) {
			GAVOI2 = 2;
		}

		if ("b".equals(pIn.get("E3-1"))) {
			GAVOI3 = 0;
		} else if ("a".equals(pIn.get("E3-1")) && "a".equals(pIn.get("E3-2"))) {
			GAVOI3 = 1;
		} else {
			GAVOI3 = 2;
		}

		int E4 = 0;
		if (!StringUtils.isBlank((String) pIn.get("E4-2"))) {
			E4 = Integer.parseInt(pIn.get("E4-2").toString());

		}

		if ("b".equals(pIn.get("E4-1"))) {
			GAVOI4 = 0;
		} else if ("a".equals(pIn.get("E4-1")) && E4 == 1 && "b".equals(pIn.get("E4-3"))) {
			GAVOI4 = 1;
		} else if ("a".equals(pIn.get("E4-1")) && E4 > 1 && "b".equals(pIn.get("E4-3"))) {
			GAVOI4 = 1.5;
		} else if ("a".equals(pIn.get("E4-1")) && "a".equals(pIn.get("E4-3"))) {
			GAVOI4 = 2;
		}

		if ("a".equals(pIn.get("E5"))) {
			GAVOI5 = 0;
		} else if ("b".equals(pIn.get("E5"))) {
			GAVOI5 = 1;
		} else if ("c".equals(pIn.get("E5"))) {
			GAVOI5 = 2;
		}
		double GAVOIT = GAVOI1 + GAVOI2 + GAVOI3 + GAVOI4 + GAVOI5;
		return GAVOIT;
	}

	// 计算ICNFLT
	private static double getICNFLT(JSONObject pIn) {
		double ICNFLT = 0;
		if ("a".equals(pIn.get("G5")) && "b".equals(pIn.get("G5"))) {
			ICNFLT = 0;
		} else if ("c".equals(pIn.get("G5"))) {
			ICNFLT = 0.5;
		} else if ("d".equals(pIn.get("G5"))) {

		}
		return ICNFLT;
	}

	// 计算CCNFLT
	private static double getCCNFLT(JSONObject pIn) {
		double CCNFL1 = 0;
		double CCNFL2 = 0;
		double CCNFL3 = 0;
		if ("a".equals(pIn.get("G6"))) {
			CCNFL1 = 0;
		} else if ("b".equals(pIn.get("G6"))) {
			CCNFL1 = 0.5;
		} else if ("c".equals(pIn.get("G6"))) {
			CCNFL1 = 1;
		} else if ("d".equals(pIn.get("G6"))) {
			CCNFL1 = 2;
		}

		if ("a".equals(pIn.get("G8"))) {
			CCNFL2 = 0;
		} else if ("b".equals(pIn.get("G8"))) {
			CCNFL2 = 0.5;
		} else if ("c".equals(pIn.get("G8"))) {
			CCNFL2 = 1;
		} else if ("d".equals(pIn.get("G8"))) {
			CCNFL2 = 2;
		}

		if ("a".equals(pIn.get("G9"))) {
			CCNFL3 = 0;
		} else if ("b".equals(pIn.get("G9"))) {
			CCNFL3 = 0.5;
		} else if ("c".equals(pIn.get("G9"))) {
			CCNFL3 = 1;
		} else if ("d".equals(pIn.get("G9"))) {
			CCNFL3 = 2;
		}

		double CCNFLT = CCNFL1 + CCNFL2 + CCNFL3;
		return CCNFLT;
	}

	// 计算OCNFLT
	private static double getOCNFLT(JSONObject pIn) {
		double OCNFL1 = 0;
		double OCNFL2 = 0;
		double OCNFL3 = 0;
		if ("a".equals(pIn.get("F4"))) {
			OCNFL1 = 0;
		} else if ("b".equals(pIn.get("F4"))) {
			OCNFL1 = 0.5;
		} else if ("c".equals(pIn.get("F4"))) {
			OCNFL1 = 1;
		} else if ("d".equals(pIn.get("F4"))) {
			OCNFL1 = 2;
		}

		if ("a".equals(pIn.get("G10-1"))) {
			OCNFL2 = 0;
		} else if ("b".equals(pIn.get("G10-1"))) {
			OCNFL2 = 0.5;
		} else if ("c".equals(pIn.get("G10-1"))) {
			OCNFL2 = 1;
		} else if ("d".equals(pIn.get("G10-1"))) {
			OCNFL2 = 2;
		}

		if ("b".equals(pIn.get("G11"))) {
			OCNFL3 = 0.5;
		} else if ("c".equals(pIn.get("G11"))) {
			OCNFL3 = 1;
		} else if ("d".equals(pIn.get("G11"))) {
			OCNFL3 = 2;
		} else {
			OCNFL3 = 0;
		}
		double add = 0;
		if ("e".equals(pIn.get("J6"))) {
			add = add + 0.5;
		}
		if ("a".equals(pIn.get("J7"))) {
			add = add + 0.5;
		}
		if ("c".equals(pIn.get("J8"))) {
			add = add + 0.5;
		}
		if ("e".equals(pIn.get("J9")) || "d".equals(pIn.get("J9"))) {
			add = add + 0.5;
		}
		OCNFL3 = OCNFL3 + add;
		if (OCNFL3 > 2) {
			OCNFL3 = 2;
		}
		double OCNFLT = OCNFL1 + OCNFL2 + OCNFL3;
		return OCNFLT;
	}

	// 计算GCNFLT
	private static double getGCNFLT(JSONObject pIn) {
		double GCNFL1 = 0;
		double GCNFL2 = 0;
		double GCNFL3 = 0;
		double GCNFL4 = 0;
		double GCNFL5 = 0;
		double GCNFL6 = 0;
		double GCNFL7 = 0;
		if ("a".equals(pIn.get("J10"))) {
			GCNFL1 = 0;
		} else if ("b".equals(pIn.get("J10"))) {
			GCNFL1 = 0.5;
		} else if ("c".equals(pIn.get("J10"))) {
			GCNFL1 = 1;
		} else if ("d".equals(pIn.get("J10"))) {
			GCNFL1 = 2;
		}

		if ("a".equals(pIn.get("G2"))) {
			GCNFL2 = 0;
		} else if ("b".equals(pIn.get("G2"))) {
			GCNFL2 = 0.5;
		} else if ("c".equals(pIn.get("G2"))) {
			GCNFL2 = 1.5;
		} else if ("d".equals(pIn.get("G2"))) {
			GCNFL2 = 2;
		}

		if ("a".equals(pIn.get("C3-1"))
				|| ("b".equals(pIn.get("C3-1")) && ("a".equals(pIn.get("C3-2")) || "b".equals(pIn.get("C3-2"))))) {
			GCNFL3 = 0;
		} else if ("a".equals(pIn.get("C3-1")) && "c".equals(pIn.get("C3-2"))) {
			GCNFL3 = 1;
		} else if ("a".equals(pIn.get("C3-1")) && "d".equals(pIn.get("C3-2"))) {
			GCNFL3 = 2;
		}

		if ("a".equals(pIn.get("J11-1"))) {
			GCNFL4 = 0;
		} else if ("b".equals(pIn.get("J11-1"))) {
			GCNFL4 = 0.5;
		} else if ("c".equals(pIn.get("J11-1"))) {
			GCNFL4 = 1.5;
		} else if ("d".equals(pIn.get("J11-1"))) {
			GCNFL4 = 2;
		}

		if ("a".equals(pIn.get("J12"))) {
			GCNFL5 = 0;
		} else if ("b".equals(pIn.get("J12"))) {
			GCNFL5 = 1;
		} else if ("c".equals(pIn.get("J12"))) {
			GCNFL5 = 2;
		}

		if ("a".equals(pIn.get("K7"))) {
			GCNFL6 = 2;
		} else if ("c".equals(pIn.get("A3"))) {
			GCNFL6 = 1;
		} else {
			GCNFL6 = 0;
		}

		if ("a".equals(pIn.get("H7"))) {
			GCNFL7 = 0;
		} else if ("b".equals(pIn.get("H7"))) {
			GCNFL7 = 1;
		} else if ("c".equals(pIn.get("H7"))) {
			GCNFL7 = 2;
		}

		double OCNFLT = GCNFL1 + GCNFL2 + GCNFL3 + GCNFL4 + GCNFL5 + GCNFL6 + GCNFL7;
		return OCNFLT;
	}

	static String[] concat(String[] a, String[] b) {
		String[] c = new String[a.length + b.length];
		System.arraycopy(a, 0, c, 0, a.length);
		System.arraycopy(b, 0, c, a.length, b.length);
		return c;
	}

}
